<?php
/**
 * Created by PhpStorm.
 * User: Bolot
 * Date: 05.12.13
 * Time: 15:52
 */

class Model_Category extends ORM {

  protected $_rules = array(
    'title' => array(
      'not_empty'  => NULL,
      'min_length' => array(1),
      'max_length' => array(255),
      'regex'      => array('/^[-\pL\pN_.]++$/uD'),
    ),
    'description' => array(
      'not_empty'  => NULL,
      'min_length' => array(1),
      'max_length' => array(100000),
      'regex'      => array('/^[-\pL\pN_.]++$/uD'),
    ),
  );

  public function getItem($id)
  {
    $s = $this->find_all(
      $this->where('category_id', '=', $id)
        ->limit(1)
    );
    foreach ($s as $c){
      return $c;
    }
    return false;
  }
}